package com.feng.springmvc.controller;

import com.feng.springmvc.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;

//@Controller
@RestController
public class UserController {

    @RequestMapping("/j2")
    //@ResponseBody
    public String test2(){
        User user = new User(101, "feng风", "女");
//        return user.toString();
        return "main";
    }

    @RequestMapping(value = "/j3",produces = "application/json;charset=utf-8")
    @ResponseBody
    public String test3(){
        User user = new User(101, "feng风", "女");
        return user.toString();
//        return "main";
    }

    @RequestMapping(value = "/j4")
    @ResponseBody
    public String test4(){
        User user = new User(101, "feng风", "女");
        return user.toString();
//        return "main";
    }

    @RequestMapping(value = "/j5")
//    @ResponseBody
    public String test5(){
        User user = new User(101, "feng风", "女");
        return user.toString();
//        return "main";
    }

    @RequestMapping(value = "/j6")
//    @ResponseBody
    public String test6(){
        Date date = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String datetime = dateFormat.format(date);
        return datetime;
//        return "main";
    }
}
